package com.tang.algorithm.array;

/**
 * @author tlm
 * @version 1.0
 * @date 2020/7/19 15:25
 *
 */
public class LeetCode1475 {
    public static void main(String[] args) {
        int[] a = {10,1,1,6};
        int[] res = finalPrices(a);
        for (int i = 0; i <res.length ; i++) {
            System.out.println(res[i]);
        }
    }
    public static int[] finalPrices(int[] prices) {
        int[] res = new int[prices.length];
        for (int i = 0; i <prices.length ; i++) {
            if(i==prices.length-1) res[i] = prices[i];
            for (int j = i+1; j < prices.length ; j++) {
                if(prices[j]<=prices[i])
                {
                    res[i] = prices[i]-prices[j];
                    break;
                }
                if(j==prices.length-1)  res[i] = prices[i];
            }

        }
        return res;
    }
}
